package core.genetic.mutation.single;

import static java.lang.Math.*;

import java.util.*;

import core.*;

import utility.*;

public class NormalSlowingMutation implements SingleGeneMutation
{

	private double normalDist()
	{
		Random r = Utils.random;
		return r.nextGaussian();
//		double a = r.nextDouble();
//		double b = r.nextDouble();
//
//		double c = sqrt(-1 * log(a)) * cos(2 * PI * b);
//		// double d = sqrt(-2 * log(a)) * sin(2 * PI * b);
//		return c;
	}

	@Override
	public double getMutated(double oldValue) {
		return max(-1, min(1,oldValue + 4*Math.pow(0.7, Math.log(Mode.mode.currentGeneration))*normalDist()));
	}

}
